home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / msdos / s3tool10.zip / TSTQUERY.BAT < prev    next >
DOS Batch File  |  1993-09-25  |  2KB  |  78 lines

  1. @echo off
  2.  
  3. REM **********************************
  4. REM * S3 QUERY TEST/DEMO BATCH FILE  *
  5. REM * BY:  George Spafford           *
  6. REM * Tested in MS DOS 5.0           *
  7. REM * version 1.0  09/25/93          *
  8. REM * Requires the S3 Software QUERY *
  9. REM * program for DOS in order to run*
  10. REM **********************************
  11. REM * If you learn from this batch   *
  12. REM * file, then please register your*
  13. REM * copy of S3 Tools.              *
  14. REM **********************************
  15.  
  16. cls
  17. :aDEMO
  18.  echo Press the lowercase (a) now.  The batch file will only continue if you
  19.  echo press the lowercase (a) key.
  20.  
  21.  query 97
  22.  REM The above line expressly states that an ASCII code of 97 must be entered
  23.  REM before continuing on.
  24.  
  25.  if errorlevel 97 echo (a) was pressed
  26.  
  27. :abcDEMO
  28.  echo.
  29.  echo.
  30.  echo Now, press either lowercase a, b or c.  QUERY will watch for one of those
  31.  echo three characters to be pressed before it continues on.
  32.  
  33.  query 97-99
  34.  REM The above line tells S3 QUERY that the user must press a, b or c.
  35.  REM They are the keys that return ASCII codes 97, 98 and 99 respectively.
  36.  
  37.  REM Note that you should test errorlevels from the highest possible value
  38.  REM to the lowest.  Here, we know that 99 is the highest and 97 the lowest.
  39.  REM I personally really wish Microsoft had designed the errorlevels to be
  40.  REM a true Boolean equals rather than equal to or greater than.
  41.  REM Also, gosub would have been nice.  With Mr. Gates saying that the DOS
  42.  REM era is coming to a close, I suppose they will never add the enhancements.
  43.  
  44.  if errorlevel 99 goto ABC_c
  45.  if errorlevel 98 goto ABC_b
  46.  if errorlevel 97 goto ABC_a
  47.  
  48. :ABC_c
  49.  echo (c) was pressed
  50.  goto ESCdemo
  51.  
  52. :ABC_b
  53.  echo (b) was pressed
  54.  goto ESCdemo
  55.  
  56. :ABC_a
  57.  echo (a) was pressed
  58.  goto ESCdemo
  59.  
  60. :ESCdemo
  61.  echo.
  62.  echo.
  63.  echo OK now press the ESCape key.  The batch file will continue regardless
  64.  echo of what you press but only the ESCape key will perform the correct task
  65.  query
  66.  
  67.  REM The next line is an error trap.  A batch file equal sign really means
  68.  REM greater than or equal to.  Thus, if errorlevel=28 was omitted, then
  69.  REM the batch file will say ESC was pressed as long as the return code was
  70.  REM greater than or equal to 27.
  71.  
  72.  if errorlevel 28 goto FINISH
  73.  if errorlevel 27 echo ESC was pressed
  74.  
  75. :FINISH
  76.  echo.
  77.  echo.
  78.